<template>
    <div>
        <el-header style="text-align: right; font-size: 15px">
            <span>
                欢迎使用学籍管理系统-修改学历
            </span>
        </el-header>
        <el-form :data="formLabelAlign"  style="margin-top:25px" :ref="formLabelAlign" :label-position="labelPosition" label-width="80px" label-position="50%" >
            <el-form-item label="学号">
                <el-input v-model="formLabelAlign.s_id" readonly></el-input>
            </el-form-item>
            <el-form-item label="姓名">
                <el-input v-model="formLabelAlign.s_name" readonly></el-input>
            </el-form-item>
            <el-form-item label="初中">
                <el-input v-model="formLabelAlign.r_junior"></el-input>
            </el-form-item>
            <el-form-item label="高中">
                <el-input v-model="formLabelAlign.r_high"></el-input>
            </el-form-item>
            <el-form-item label="大学">
                <el-input v-model="formLabelAlign.r_university"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="submitForm('formLabelAlign')">确认修改/新增</el-button>
                <el-button type="primary" @click="resetForm('formLabelAlign')">重置</el-button>
                <el-button type="primary" @click="backForm('formLabelAlign')">返回首页</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                labelPosition: 'top',
                formLabelAlign: {
                    s_id: '111',
                    s_name: '',
                    r_junior: '',
                    r_high: '',
                    r_university: ''
                }
            };
        },
        created() {
            const _this = this
            axios.get('http://localhost:8181/student2/getOne/' + this.$route.query.id).then(function (resp) {
                _this.formLabelAlign = resp.data[0]
            })
        },
        methods: {
            submitForm(formName) {
                const _this=this
                axios.post('http://localhost:8181/student2/save',this.formLabelAlign).then(function (resp) {
                    if(resp.data =='success'){
                        _this.$message({
                            message: '修改成功！',
                            type: 'success'
                        });
                    }
                })
            },
            backForm(formName) {
                this.$router.push('/Page1')
            },
            resetForm(formName){
                const _this = this
                axios.get('http://localhost:8181/student2/getOne/' + this.$route.query.id).then(function (resp) {
                    _this.formLabelAlign = resp.data[0]
                })
            }
        }
    }

</script>